package com.tianxiao.faas.application.web.corner;

import com.tianxiao.faas.api.param.corner.BasePageParam;
import com.tianxiao.faas.api.param.corner.CustomInfoResult;
import com.tianxiao.faas.biz.service.corner.CustomInfoService;
import com.tianxiao.faas.common.access.Access;
import com.tianxiao.faas.common.result.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/app/admin/info/")
public class CustomInfoAdminController {

    @Resource
    private CustomInfoService customInfoService;

    @RequestMapping(value = "/list")
    @Access(access = {"admin"})
    public Result<List<CustomInfoResult>> list(@RequestBody BasePageParam param) {
        List<CustomInfoResult> results = customInfoService.list(param);
        Integer count = customInfoService.count();
        return Result.builder().success(true).data(results).totalCount(count).pageNo(param.getPage())
                .pageSize(param.getPageSize()).totalPage();
    }
}
